package com.chinasofti.project.service.user.impl;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.chinasofti.project.common.pageQuery.PageResult;
import com.chinasofti.project.dal.mapper.custom.MyOrdersMapperCustom;
import com.chinasofti.project.dal.model.custom.MyOrders;
import com.chinasofti.project.service.user.LineItemService;
import com.chinasofti.project.service.user.info.LineItemInfo;

@Service("lineItemService")
public class LineItemServiceImpl implements LineItemService {
	
	private Logger logger = LoggerFactory.getLogger(LineItemServiceImpl.class);
	
	@Autowired
	public MyOrdersMapperCustom myOrdersMapperCustom;

	@Override
	public PageResult displayTheOrder(LineItemInfo lineItemInfo) {

		long totalCount = myOrdersMapperCustom.selectLineItemTotalCount(lineItemInfo.getUserId());

		List<MyOrders> orders = myOrdersMapperCustom.selectByLineItemIdList(lineItemInfo);

		return new PageResult(totalCount, lineItemInfo.getPageSize(), orders);
	}

	/**
	 * @param pageIdxStr
	 * @return
	 */
	private long getPageIdx(long pageIdxStr) {

		return pageIdxStr == 0 ? 1 : pageIdxStr;

	}

}


